package day2.demo2.controller;

import day2.demo2.entity.Result;
import day2.demo2.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;

@RestController
@RequestMapping("/sal")
public class ProductCtrl {
    @Autowired
    ProductService service;
    @GetMapping("/product")
    public Result findAll(HttpSession session){
        Result rs = new Result();
        rs.setObj(service.findAllProducts());
        rs.setRs(true);
        rs.setExtra((String)session.getAttribute("username"));
        return rs;
    }
}